package test19.outputstream_;

import java.io.*;

public class BufferedCopy02 {
    public static void main(String[] args) throws IOException {
        // 演示使用BufferedOutputStream 和 BufferedInputStream使用
        // 使用他们，可以完成二进制文件拷贝.
        String srcFilePath = "D:\\资料\\分散实习申请表.docx";
        String destFilePath = "D:\\资料\\分散实习申请表2.docx";
        byte[] buf = new byte[1024];
        int readLen = 0;

        BufferedInputStream bufferedInputStream = new BufferedInputStream(new FileInputStream(srcFilePath));
        BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(destFilePath));
        while((readLen = bufferedInputStream.read(buf)) != -1){
            bufferedOutputStream.write(buf,0,readLen);
        }
        System.out.println("文件拷贝完成");
        bufferedInputStream.close();
        bufferedOutputStream.close();
    }
}
